@echo off

REM Set these values to match their location
SET SVN_EXE="c:\Program Files\svn-win32-1.4.5\bin\svn.exe"
SET JSBUILDER_EXE="C:\Program Files\JS Builder\JSBuildConsole.exe"
SET BSDTAR_EXE="C:\Program Files\GnuWin32\bin\bsdtar.exe"
SET SVN_AUTH_DIR="C:/Documents And Settings/Administrator/Application Data/Subversion/auth/"

REM Get current date
for /f "tokens=1,2" %%u in ('date /t') do set d=%%v 
for /f "tokens=1" %%u in ('time /t') do set t=%%u 
if "%t:~1,1%"==":" set t=0%t% 
rem set timestr=%d:~6,4%%d:~3,2%%d:~0,2%%t:~0,2%%t:~3,2% 
set datestr=%d:~6,4%%d:~0,2%%d:~3,2% 
set timestr=%t:~0,2%%t:~3,2% 
SET CURRENT_DATE=%datestr:~0,8%

REM Build variables
SET ARCHIVE_DIR=extjstoolkit-%CURRENT_DATE%
SET BUILD_FILE=extjstoolkit-nightly-%CURRENT_DATE%.tar.gz

rmdir /q /s build

%SVN_EXE% update
%JSBUILDER_EXE% /path=ExtJSToolkit.jsb /clean /output=build /verbose
xcopy /E examples build\examples\

REM Create the archive file
mkdir build_target
cd build_target
mkdir %ARCHIVE_DIR%
xcopy /E ..\build\*.* %ARCHIVE_DIR%
%BSDTAR_EXE% zcvf %BUILD_FILE% %ARCHIVE_DIR%/*.*
move %BUILD_FILE% ..\build
cd ..
rmdir /q /s build_target
